//
//  DIYChoiceCarTableViewCell.m
//  UcarTest
//
//  Created by 陈曦 on 16/1/14.
//  Copyright © 2016年 chenxi. All rights reserved.
//

#import "DIYChoiceCarTableViewCell.h"
#import "Define.h"
#import "UIImageView+WebCache.h"
#import "NetRequestGroup.h"
#define kHightOfBgview kScreenWidth * 221 / 375 - 10

@implementation DIYChoiceCarTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        //添加背景色
        self.backgroundColor = backgroundMainColor;
        
        //底层视图
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(10, 5, kScreenWidth - 20, kHightOfBgview)];
        self.bgView.layer.cornerRadius = 2;
        self.bgView.layer.shadowOpacity = 1.0;
        self.bgView.layer.shadowOffset = CGSizeMake(0.0, 0.0);
        self.bgView.layer.shadowColor = [UIColor grayColor].CGColor;
        self.bgView.layer.shadowRadius = 2.0;
        [self addSubview:self.bgView];
        
        //汽车图片
        self.carImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 20, kHightOfBgview)];
        self.carImageView.layer.cornerRadius = 2;
        self.carImageView.layer.masksToBounds = YES;
        [self.bgView addSubview:self.carImageView];
        
        //详情视图图片
        self.detailImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, kHightOfBgview - 60, kScreenWidth - 20, 60)];
        self.detailImageView.image = [UIImage imageNamed:@"bg－white－lucency"];
        [self.bgView addSubview:self.detailImageView];
        
        //汽车标签图片
        self.carLabelImageView = [[UIImageView alloc] initWithFrame:CGRectMake( 7, 10, 16, 7)];
        self.carLabelImageView.image = [UIImage imageNamed:@"iconfont-car-blue"];
        [self.detailImageView addSubview:self.carLabelImageView];
        
        //车名标签
        self.carNameLabel = [[UILabel alloc] initWithFrame:CGRectMake( 33, 5, 30, 16)];
        self.carNameLabel.text = @"奥迪";
        self.carNameLabel.textAlignment = NSTextAlignmentLeft;
        self.carNameLabel.textColor = mainColor ;
        self.carNameLabel.font = [UIFont boldSystemFontOfSize:14];
        [self.detailImageView addSubview:self.carNameLabel];
        
        //车型标签
        self.carModelLabel = [[UILabel alloc] initWithFrame:CGRectMake(63, 5, 30, 16)];
        self.carModelLabel.text = @"A6";
        self.carModelLabel.textAlignment = NSTextAlignmentLeft;
        self.carModelLabel.textColor = mainColor ;
        self.carModelLabel.font = [UIFont boldSystemFontOfSize:14];
        [self.detailImageView addSubview:self.carModelLabel];

        //是否自排标签
        self.automaticLabel = [[UILabel alloc] initWithFrame:CGRectMake(95, 7, 25, 14)];
        self.automaticLabel.text = @"自排";
        self.automaticLabel.font = [UIFont systemFontOfSize:10];
        self.automaticLabel.textAlignment = NSTextAlignmentLeft;
        [self.detailImageView addSubview:self.automaticLabel];
        
        //定位图片
        self.positionImageview = [[UIImageView alloc] initWithFrame:CGRectMake(7, 30, 17, 21)];
        self.positionImageview.image = [UIImage imageNamed:@"iconfont-locate"];
        [self.detailImageView addSubview:self.positionImageview];
        
        //具体位置
        self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(33, 35, 200, 16)];
        self.addressLabel.textAlignment = NSTextAlignmentLeft;
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        [self.detailImageView addSubview:self.addressLabel];
        
        //价格标签
        self.priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 140, 13, 72, 24)];
//        self.priceLabel.text = @"200";
        self.priceLabel.textColor = mainColor;
        self.priceLabel.font = [UIFont systemFontOfSize:20];
        self.priceLabel.textAlignment = NSTextAlignmentRight;
        [self.detailImageView addSubview:self.priceLabel];
        
        //单位标签
        self.unitLabel = [[UILabel alloc] initWithFrame:CGRectMake( kScreenWidth - 66, 20, 46, 14)];
        self.unitLabel.text = @"元 / 天";
        self.unitLabel.font = [UIFont systemFontOfSize:12];
        self.unitLabel.textAlignment = NSTextAlignmentCenter;
        [self.detailImageView addSubview:self.unitLabel];
        
    }
    
    return self;

}


- (void)setModel:(CarListMianPageModel *)model{
    
    _model = model;
    
    NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRealmNameImage,model.left_img_small];

    [_carImageView  sd_setImageWithURL:[NSURL URLWithString:urlStr]];
    
    _carNameLabel.text = model.brand_str;//车名
    
    _carModelLabel.text = model.model_str;//车型
    
    _automaticLabel.text = model.speed_box;//排量
    
    _priceLabel.text = model.rent_member_money;//日租金
    
    _addressLabel.text = model.car_address;//地址
    
    _carId = model.carID;
    
}





















@end
